//
//  SMoreViewController.m
//  News
//
//  Created by dlios on 15-5-13.
//  Copyright (c) 2015年 PEAK. All rights reserved.
//

#import "SMoreViewController.h"
#import "SDuanziViewController.h"
#import "STupianViewController.h"
#import "SDianyingViewController.h"
#import "SLvyouViewController.h"
#import "RPSlidingMenuLayout.h"
#import "RPSlidingMenuCell.h"
#import "UIImageView+WebCache.h"

#import "SMoreTableViewCell.h"
@interface SMoreViewController ()<UITableViewDataSource, UITableViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource>
@property(nonatomic, retain)UIButton *travelButton;
@property(nonatomic, retain)UIImageView *travellImg;

@property(nonatomic, retain)UIButton *filmButton;
@property(nonatomic, retain)UIImageView *filmImg;

@property(nonatomic, retain)UIButton *picButton;
@property(nonatomic, retain)UIImageView *picImg;

@property(nonatomic, retain)UIButton *happyButton;
@property(nonatomic, retain)UIImageView *happyImg;


//存放名字的数组
@property(nonatomic, retain)NSMutableArray *NameArr;

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

@property(nonatomic,retain)UICollectionView *collectionView;


@end

@implementation SMoreViewController
- (void)dealloc
{
    [_travellImg release];
    [_filmImg release];
    [_picImg release];
    [_happyImg release];
    [super dealloc];
}

-(void)viewDidAppear:(BOOL)animated
{
//    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0 /255.0 green:170.0 / 255.0 blue:205.0 / 255.0 alpha:1.0];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.translucent = NO;
    
//    self.tabBarController.tabBar.hidden = NO;
//    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yinji"]];
    }

- (void)viewDidLoad {
    
    
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blackColor];
    //[self creatCollectView];
     self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeTextColor: [UIColor whiteColor], UITextAttributeFont:[UIFont boldSystemFontOfSize:20]};
    
    self.NameArr = [@[@"图片", @"段子", @"电影", @"旅游"]mutableCopy];
    
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    [self creatTableView];
    
}

- (void)creatTableView
{
    UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, SCREEN_HEIGHT / 3.03)];
    img.image = [UIImage imageNamed:@"W8"];
    [self.view addSubview:img];

    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,img.bounds.size.height , SCREEN_WIDTH, SCREEN_HEIGHT/1.1) style:UITableViewStylePlain];
    tableView.rowHeight = SCREEN_HEIGHT/8;
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];
    [tableView release];
    
   }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _NameArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SMoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"str"];
    if (cell==nil) {
        cell = [[[SMoreTableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:@"str"] autorelease];
        
    }
    
    cell.MyimageView.image = [UIImage imageNamed:@"5557d4"];
    cell.MyLabel.text = _NameArr[indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [NetworkHandle startNetMonitoringWithCompletion:^(id result) {
        
                NSString *str = [result objectForKey:@"info"];
                if ([str isEqualToString:@"无网络,请检查手机能否上网!"]) {
                    UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"提示" message:str delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                    [al show];
                }
        
            }];
        
        
        
            if ([_NameArr[indexPath.row] isEqualToString:@"图片"]) {
        
                STupianViewController *pic = [[STupianViewController alloc]init];
        
                [self.navigationController pushViewController:pic animated:YES];
                [pic release];
            }
            if ([_NameArr [indexPath.row] isEqualToString:@"段子"]) {
        
                SDuanziViewController *happy = [[SDuanziViewController alloc] init];
                [self.navigationController pushViewController:happy animated:YES];
                [happy release];
            }
            if ([_NameArr[indexPath.row] isEqualToString:@"电影"]) {
                SDianyingViewController *film = [[SDianyingViewController alloc] init];
                [self.navigationController pushViewController:film animated:YES];
                [film release];
            }
            if ([_NameArr[indexPath.row] isEqualToString:@"旅游"])
            {
                SLvyouViewController *travel = [[[SLvyouViewController alloc] init] autorelease];
                [self.navigationController pushViewController:travel animated:YES];
            
            
}
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
@end
